const fs = require('fs')

function renameFiles() {
	files = fs.readdirSync('.')
	const wfiles = files.filter(fname => fname.startsWith('word'))
	fnum = fname => parseInt(fname.replace('words', ''))
	wfiles.sort((a, b) => fnum(a) - fnum(b))

	console.log(wfiles.join('\n'));
	wfiles.forEach((fname, i) => {
	   fs.renameSync(fname, 'bookOneLit' + (i + 1))	
	})


}


function main() {
	const files = fs.readdirSync('.')
	const tfiles = files.filter(fname => { return /.*Lit.*/.test(fname) })

	fnum = fname => parseInt(fname.replace(/^[a-z]/ig, ''))

	tfiles.forEach(fname => {
		fs.renameSync(fname, fname.replace(/\d+/, m => m.padStart(4, '0')) + '.txt')
	})

	console.log('done..')

}

main()

